/**
 * Copyright (c) 2009 Teoti Graphix, LLC See:
 *     http://tkarchitecture.teotigraphix.org
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 * 
 * @author Michael Schmalle mschmalle@teotigraphix.com
 */
package test.suite.dxframework.support.component
{

import flash.events.IEventDispatcher;

import mx.controls.TextInput;

import org.teotigraphix.dx.interfaces.IComponentBehavior;
import org.teotigraphix.dx.interfaces.IComponentModel;
import org.teotigraphix.dx.patterns.component.DXComponent;

import test.suite.dxframework.support.component.factory.TestToolKitComponentFactory;

public class TestComponent extends DXComponent
{
	[StyleBinding]
	public var myComponentStyleBinding:String = "originalBindingValue";	
	
	[Bindable]
//	[SkinPart]
	public var mySkinPart:TextInput;
	
	public function TestComponent()
	{
		super();
		
//		setStyle("skinClass", TestComponentSkin);
		
		// for testing purposes only
		toolKitFactory = new TestToolKitComponentFactory();
	}
	
	public var initializeToolKitFlag:Boolean = false;
	public var invalidateSkinFlag:Boolean = false;
	public var activateFlag:Boolean = false;
	public var startToolKitFlag:Boolean = false;
	public var stopToolKitFlag:Boolean = false;
	public var stylesInitializedFlag:Boolean = false;
	
	override public function initializeToolKit():void
	{
		super.initializeToolKit();
		
//		toolKitFactory = new TestToolKitComponentFactory();
		
		initializeToolKitFlag = true;
	}
	
	
	override public function invalidateSkin():void
	{
		super.invalidateSkin();
		invalidateSkinFlag = true;
	}
	
	override public function activate(host:IEventDispatcher):void
	{
		super.activate(host);
		activateFlag = true;
	}
		
	override public function startToolKit():void
	{
		super.startToolKit();
		startToolKitFlag = true;
	}
	
	override public function stopToolKit():void
	{
		super.stopToolKit();
		stopToolKitFlag = true;
	}
	
	override public function stylesInitialized():void
	{
		super.stylesInitialized();
		stylesInitializedFlag = true;
	}	
	
	
	public var behaviorAddedObject:Object = {};
	public var behaviorRemovedObject:Object = {};
	public var modelAddedObject:Object = {};
	public var modelRemovedObject:Object = {};
	
	override protected function behaviorAdded(api:Class, behavior:IComponentBehavior):void
	{
		super.behaviorAdded(api, behavior);
		
		behaviorAddedObject.api = api;
		behaviorAddedObject.behavior = behavior;
	}
	
	override protected function behaviorRemoved(api:Class, behavior:IComponentBehavior):void
	{
		super.behaviorRemoved(api, behavior);
		
		behaviorRemovedObject.api = api;
		behaviorRemovedObject.behavior = behavior;
	}
	
	override protected function modelAdded(api:Class, model:IComponentModel):void
	{
		super.modelAdded(api, model);
		
		modelAddedObject.api = api;
		modelAddedObject.model = model;
	}
	
	override protected function modelRemoved(api:Class, model:IComponentModel):void
	{
		super.modelRemoved(api, model);
		
		modelRemovedObject.api = api;
		modelRemovedObject.model = model;		
	}			
		
}
}